const uname = JSON.parse(localStorage.getItem('nowLogin'))
const date = new Date()
let month = date.getMonth() + 1
const day = date.getDate()
let arr = JSON.parse(localStorage.getItem(`${uname}+${month}+${day}`))
let arrTom = JSON.parse(localStorage.getItem(`${uname}+${month}+${day+1}`))

// let arrTom = localStorage.setItem(`${uname}+${month}+${day+1}`, JSON.stringify(arr))

// 今天与明天的tab切换
const cutData = document.querySelector('.cut_data')
const selects = cutData.querySelectorAll('[name]')
let sel
selects.forEach(function(item) {
    item.addEventListener('click', function(e) {
        selects.forEach(function(item) {
            item.removeAttribute('id')
        })
        e.target.setAttribute('id', 'active')
        sel = e.target.getAttribute('name')
    })
})



// 存储任务
const confirm = document.querySelector('.confirm')
const addPlan = document.querySelector('.addPlan')

confirm.addEventListener('click', function(e) {
    if (addPlan.value != '') {
        console.log(arr);
        if (sel === 'tomorrow') {
            arrTom.push(addPlan.value)
            localStorage.setItem(`${uname}+${month}+${day+1}`, JSON.stringify(arrTom))
        } else {
            arr.push(addPlan.value)
            localStorage.setItem(`${uname}+${month}+${day}`, JSON.stringify(arr))
        }
    }
    addPlan.value = ''
})